package Test;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        System.out.println("请输入无向图节点个数：");
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();     // 无向图节点个数
        System.out.println("请输入需判定的无向图邻接矩阵：");
        int[][] matrix = new int[n][n];

        System.out.print(" ");
        for (int i = 1; i <= n; i++)
            System.out.print(" " + i);
        System.out.println();

        for (int i = 0; i < n; i++) {       // 输入图的邻接矩阵
            System.out.print(i + 1);
            for (int j = 0; j < n; j++) {
                matrix[i][j]=input.nextInt();
            }
        }
        Graph graph = new Graph(matrix, n);
        System.out.println(graph.Judge()?"此图为连通图":"此图为非连通图");
        if (graph.Judge()==false)       // 如果是非连通图，不需要进一步判断
            return;
        graph.JudgeEuler();
    }
}

